package novel.spider.util;

import novel.spider.NovelSiteEnum;
import novel.spider.impl.chapter.BxwxChapterSpider;
import novel.spider.impl.chapter.DefaultChapterSpider;
import novel.spider.interfaces.IChapterSpider;

/**
 * Created by Kau on 2016/10/31.
 */
public final class ChapterSpiderrFactory {
    private ChapterSpiderrFactory(){}

    /**
     * 通过给定的URL，返回一个实现了IChapterSpider接口的实现类
     * @param url
     * @return
     */
    public static IChapterSpider getChapterSpider(String url){
        NovelSiteEnum novelSiteEnum = NovelSiteEnum.GetEnumByUrl(url);
        IChapterSpider chapterSpider = null;
        switch (novelSiteEnum){
            case BiXiaWenXue :
                chapterSpider = new BxwxChapterSpider(); break;
            case DingDianXiaoShuo:
            case BiQuGe:
            case KanShuZhong:
            case BiQuGe2:
                chapterSpider = new DefaultChapterSpider();
        }
        return chapterSpider;
    }
}
